# Contributor: Raed Rizqie <raed.rizqie@gmail.com>

_realname=qdarkstyle
pkgbase=mingw-w64-python-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-python-${_realname}
pkgver=3.0.3
pkgrel=1
pkgdesc='The most complete dark/light style sheet for C++/Python and Qt applications (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
license=('spdx:MIT')
url='https://github.com/ColinDuquesnoy/QDarkStyleSheet'
depends=(
    ${MINGW_PACKAGE_PREFIX}-python
    ${MINGW_PACKAGE_PREFIX}-python-pyqt5
    ${MINGW_PACKAGE_PREFIX}-python-qtpy
)
makedepends=(
    ${MINGW_PACKAGE_PREFIX}-python-setuptools)
source=(https://github.com/ColinDuquesnoy/QDarkStyleSheet/archive/v${pkgver}.tar.gz)
sha256sums=('5b74055750c14efec250a1c0307c2f21db9517eb63c0af009af5a06f1fce36c0')

prepare() {
  cd "${srcdir}"
  rm -rf python-build-${MSYSTEM} | true
  cp -r "QDarkStyleSheet-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  msg "Python build for ${MSYSTEM}"
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  for _f in "${pkgdir}${MINGW_PREFIX}"/bin/*-script.py; do
    # Remove shebang line
    sed -e '1 { s/^#!.*$// }' -i "${_f}"
  done

  install -Dm644 LICENSE.rst "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
